﻿if (typeof SiteConfig == "undefined") {
    SiteConfig = {}
}

if (typeof Version == "undefined") {
    Version = '2.0'
}

var vui_n = "?r=" + Version;
//本地执行初始化默认配置
if (location.href.indexOf("file:///") >= 0) {
    SiteConfig.FrameworkScriptUrl = "../../FrameWeb/FrameScripts/";
    SiteConfig.ScriptUrl = "../../Scripts/";
} 

if (typeof vui == "undefined") {
    vui = {};
    vui.Catch = {
        id: "123",
        abc: function () {
            console.log("Abc");
        }
    };
}
vui.Namespace = function (str, callFn) {
    var arr = str.split("."),
        o = vui;
    for (var i = (arr[0] == "vui") ? 1 : 0; i < arr.length; i++) {
        o[arr[i]] = o[arr[i]] || {};
        o = o[arr[i]]
    }
    var curObj = eval("vui." + str);
    if (typeof callFn == "function") {
        callFn.call(curObj)
    }
};
vui.Load = function (l, h, g) {
    if (typeof exports == "undefined") {
        exports = {};
    }
    var c, b = document.getElementsByTagName("head")[0],
        e = l instanceof Array,
        f = e ? l.length : 0,
        d = 0,
        a = 0;
    h = h ? h : "";
    var k = function (r) {
        var p = r.match(/[a-z0-9A-Z-_]*.js$/) ? "script" : "link",
            o = document.getElementsByTagName(p),
            n = false;
        for (var q = 0,
                 m = o.length; q < m; q++) {
            (function (u) {
                var s = o[u],
                    t = s.getAttribute("src") || s.getAttribute("href");
                if (t && r.toLowerCase() === t.toLowerCase()) {
                    s.parentNode.removeChild(s);
                    n = true
                }
            })(q);
            if (n) {
                break
            }
        }
        return n
    };
    var i = function (o) {
            k(o);
            c = o.match(/\.js$/) ? document.createElement("script") : document.createElement("link");
            var m = navigator.userAgent.indexOf("MSIE") > -1;
            if (m) {
                c.onreadystatechange = function () {
                    if (c.readyState && c.readyState == "loaded" || c.readyState == "complete") {
                        d++;
                        a++;
                        if (e && d <= (f - 1)) {
                            i(l[d])
                        }
                    }
                }
            } else {
                c.onload = function () {
                    d++;
                    a++;
                    if (e && d <= (f - 1)) {
                        i(l[d])
                    }
                }
            }
            if (c.nodeName.toLowerCase() === "script") {
                c.setAttribute("type", "text/javascript");
                c.setAttribute("language", "javascript");
                var n = vui_n;//"?r=" + Math.random();
                if (o.indexOf("http://") > -1) {
                    c.setAttribute("src", o + n)
                } else {
                    c.setAttribute("src", h + o + n)
                }
            } else {
                c.setAttribute("type", "text/css");
                c.setAttribute("rel", "stylesheet");
                var n = vui_n;//"?r=" + Math.random();
                if (o.indexOf("http://") > -1) {
                    c.setAttribute("href", o + n)
                } else {
                    c.setAttribute("href", h + o + n)
                }
            }
            b.appendChild(c)
        },
        j = setInterval(function () {
                if (typeof g != "function") {
                    clearInterval(j);
                    return
                }
                if ((e && a === f) || (!e && a === 1)) {
                    clearInterval(j);
                    g()
                }
            },
            1);
    if (e && f > 0) {
        i(l[d])
    } else {
        i(l)
    }
};
vui.Clone = function (jsonObj) {
    var buf;
    if (jsonObj instanceof Array) {
        buf = [];
        var i = jsonObj.length;
        while (i--) {
            buf[i] = arguments.callee(jsonObj[i]);
        }
        return buf;
    } else if (typeof jsonObj == "function") {
        return jsonObj;
    } else if (jsonObj instanceof Object) {
        buf = {};
        for (var k in jsonObj) {
            buf[k] = arguments.callee(jsonObj[k]);
        }
        return buf;
    } else {
        return jsonObj;
    }
};
var vui_PluginList = [
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/IE/media.match.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/IE/es6-shim.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/zepto/zepto.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Common.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/react/react.production.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/react/react-dom.production.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/babel/babel.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/antd/moment.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/antd/moment-with-locales.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/antd/antd.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/antd/antd-with-locales.min.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/plugin/require/require.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Template.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.ScriptUrl + "Component/vui.Template.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Url.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Page.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Data.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Cookie.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Guid.js" + vui_n + "'></script>",
    "<script type='text/javascript' src='" + SiteConfig.FrameworkScriptUrl + "vui.2.0/vui.Format.js" + vui_n + "'></script>"
];

//本地执行初始化默认配置
vui.IsLocal = true;

document.write(vui_PluginList.join(""));
// 对象扩展

